using Volo.Abp.Data;
using System.Threading.Tasks;
using Volo.Abp.Identity;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;

namespace Acme.BookStore;

public class UsersDataSeederContributor : IDataSeedContributor, ITransientDependency
{
    protected IIdentityUserRepository repository;

    protected IGuidGenerator guidGenerator;
    public UsersDataSeederContributor(IIdentityUserRepository repository, IGuidGenerator guidGenerator)
    {
        this.repository = repository;
        this.guidGenerator = guidGenerator;
    }

    public async Task SeedAsync(DataSeedContext context)
    {
        var count = await repository.GetCountAsync();
        if(count <= 1) // Not sure 'admin' user was seeded before or not.
        {
            // All the names below were generated by https://www.name-generator.org.uk/quick/
            // The names does not represent real people.
            await repository.InsertManyAsync(new []{
                new IdentityUser(guidGenerator.Create(), "john.doe", "john.doe@abp.io"),
                new IdentityUser(guidGenerator.Create(), "Zane.Frost", "Zane.Frost@abp.io"),
                new IdentityUser(guidGenerator.Create(), "Oscar.Landry", "Oscar.Landry@abp.io"),
                new IdentityUser(guidGenerator.Create(), "Yasemin.Roberts", "Yasemin.Roberts@abp.io"),
                new IdentityUser(guidGenerator.Create(), "Yasmine.Perez", "Yasmine.Perez@abp.io"),
                new IdentityUser(guidGenerator.Create(), "Tobi.Becker", "Tobi.Becker@abp.io"),
                new IdentityUser(guidGenerator.Create(), "Fox.Gilmore", "Fox.Gilmore@abp.io"),
                new IdentityUser(guidGenerator.Create(), "Benny.Burris", "Benny.Burris@abp.io"),
                new IdentityUser(guidGenerator.Create(), "Chad.Camacho", "Chad.Camacho@abp.io"),
            });
        }
    }
}